﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Converters="clr-namespace:DanielVaughan.Windows.Converters;assembly=DanielVaughan.Silverlight"
    xmlns:Controls="clr-namespace:DanielVaughan.Calcium.Gui.Controls">

	<Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>

	<Style x:Key="GridSplitterPreviewStyle" TargetType="Control">
		<Setter Property="Background" Value="#FF868686"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="Control">
					<Grid x:Name="Root" Opacity=".5">
						<!-- Background -->
						<Rectangle Fill="{TemplateBinding Background}" />
						<!-- Horizontal Template -->
						<Grid x:Name="HorizontalTemplate" Height="6">
							<!-- Just show the faint gray grid splitter rectangle with no other details -->
						</Grid>
						<!-- Vertical Template -->
						<Grid x:Name="VerticalTemplate" Visibility="Collapsed" Width="6">
							<!-- Just show the faint gray grid splitter rectangle with no other details -->
						</Grid>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style x:Key="SplitterButtonStyle" TargetType="Button">
		<Setter Property="Cursor" Value="Hand" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="Button">
					<Border CornerRadius="0" Background="Gray" Opacity="0.7" >
						<TextBlock Text="{TemplateBinding Content}" FontFamily="Webdings"
                                       Foreground="Yellow"
                                       HorizontalAlignment="Center" VerticalAlignment="Center" />
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<!-- ExpandableGridSplitter Source from Ofir Shemesh
		http://shemesh.wordpress.com/2008/12/03/silverlight-gridsplitter-with-a-collapse-button-v2/ -->

	<Style TargetType="Controls:ExpandableGridSplitter">
		<Setter Property="Background" Value="#FFFFFFFF"/>
		<Setter Property="IsTabStop" Value="true"/>
		<Setter Property="PreviewStyle" Value="{StaticResource GridSplitterPreviewStyle}"/>
		<Setter Property="HorizontalAlignment" Value="Right"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="Controls:ExpandableGridSplitter">
					<Grid x:Name="Root" IsHitTestVisible="{TemplateBinding IsEnabled}">

						<VisualStateManager.VisualStateGroups>
							<VisualStateGroup x:Name="CommonStates">
								<VisualState x:Name="Normal" />
								<VisualState x:Name="MouseOver" />
								<VisualState x:Name="Disabled">
									<Storyboard>
										<DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="0.5" Duration="0" />
									</Storyboard>
								</VisualState>
							</VisualStateGroup>
							<VisualStateGroup x:Name="FocusStates">
								<VisualStateGroup.Transitions>
									<VisualTransition GeneratedDuration="0" />
								</VisualStateGroup.Transitions>
								<VisualState x:Name="Unfocused" />
								<VisualState x:Name="Focused">
									<Storyboard>
										<DoubleAnimation Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
									</Storyboard>
								</VisualState>
							</VisualStateGroup>
						</VisualStateManager.VisualStateGroups>

						<!-- Background -->
						<!-- Use fallback value in SL4 -->
						<Rectangle Fill="{TemplateBinding Background}" StrokeThickness="0" />

						<!-- Horizontal Template -->
						<Grid x:Name="HorizontalTemplate" >
							<Button Style="{StaticResource SplitterButtonStyle}" x:Name="HorizontalCollapseButton"
                                Width="50"/>
						</Grid>

						<!-- Vertical Template -->
						<Grid x:Name="VerticalTemplate" Visibility="Collapsed" >
							<Button Style="{StaticResource SplitterButtonStyle}" x:Name="VerticalCollapseButton"
                                Height="50"/>
						</Grid>

						<!-- Focus Visual -->
						<Rectangle x:Name="FocusVisual" Stroke="Gray" StrokeThickness="1" Opacity="0" IsHitTestVisible="false" />
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

</ResourceDictionary>